import { ReportViewActionType, IReportViewAbility, IParam } from '@/core/interface';
import { IReportViewController } from '@/core/interface/view/controller';
import { IReportViewStore } from '@/core/interface/view/store';
import { IReportPanelAbility } from '@/core/interface/widgets/ability';
import { MDViewController } from './md-view-controller';

/**
 * 报表视图控制器
 *
 * @export
 * @class ReportViewController
 * @extends {MDViewController}
 */
export class ReportViewController
	extends MDViewController<ReportViewActionType, IReportViewStore, IReportViewAbility>
	implements IReportViewController<IReportViewStore, IReportViewAbility>
{
	/**
	 * 获取表格部件能力
	 *
	 * @protected
	 * @return {*}  {(IReportPanelAbility | undefined)}
	 * @memberof ReportViewController
	 */
	protected getMainCtrlAbility(): IReportPanelAbility | undefined {
		const reportPanel = this.model.ctrls.find(
			(ctrl: IParam) => ctrl.controlType === 'REPORTPANEL'
		);
		if (reportPanel) {
			return this.getSubAbility<IReportPanelAbility>(reportPanel.name);
		}
		return undefined;
	}
}
